package com.sgb.kjwl.view.ui.adapter.machine;

import android.content.Context;
import android.util.DisplayMetrics;
import android.widget.LinearLayout;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemGridMechanicalBinding;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.kjwl.utils.DisplayUtil;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class LeaseListTopAdapter extends BaseRecycleAdapter<DictEntity3> {

    private DisplayMetrics dm;
    private Context mContext;
    public LeaseListTopAdapter(Context context) {
        super(context, R.layout.item_grid_mechanical, null);
        mContext = context;
    }

    @Override
    public void convert(ItemViewHolder holder, final DictEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemGridMechanicalBinding binding = (ItemGridMechanicalBinding) holder.getmBinding();
        //获取屏幕信息
        if (dm == null) {
            dm = mContext.getResources().getDisplayMetrics();
        }
        LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(binding.llGroup.getLayoutParams());
        linearParams.width = (dm.widthPixels - DisplayUtil.dip2px(mContext, 32)) / 5;
        binding.llGroup.setLayoutParams(linearParams);
    }
}
